package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.ChannelDTO;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @package com.heima.admin.controller.v1
 * @Date 2022/2/26
 * @project heima-leadnews
 */
@Api(value = "敏感词管理API", tags = "敏感词管理API")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;


    @PostMapping("/list")
    @ApiOperation("敏感词分页列表查询")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDTO sensitiveDTO) {
        return adSensitiveService.findByNameAndPage(sensitiveDTO);
    }

    @PostMapping("/save")
    @ApiOperation("敏感词添加")
    public ResponseResult insertAdsensitive(@RequestBody AdSensitive ads) {
        return adSensitiveService.insertAdsensitive(ads);
    }

    @PostMapping("/update")
    @ApiOperation("敏感词修改")
    public ResponseResult updateAdsensitive(@RequestBody AdSensitive ads) {
        return adSensitiveService.updateAdsensitive(ads);
    }

    @DeleteMapping("/del/{id}")
    @ApiOperation("敏感词删除")
    public ResponseResult deleteAdsensitive(@PathVariable Integer id) {
        return adSensitiveService.deleteAdsensitive(id);
    }

    @ApiOperation("敏感词内容查询")
    @PostMapping("/sensitives")
    public ResponseResult sensitives(){
        return adSensitiveService.selectAllSensitive();
    }
}
